<!--
* @description  : 指定项选择
* @descriptionDetail: 指定项选择
* @copyright    : 浙江烟草
* @author       : mc
* @create       : 2022-07-25 16:15:38
-->
<template>
  <view class="page"> 
    <theme-navbar
      :is-white="false"
      :isBack="false"
      backColor="#2b85e4"
      title="指定项"
    >
      <view class="nav-right-icon" @tap="onSure">
        确定
      </view>
    </theme-navbar>
    <view class="content">
      <view id="orgListContainer">
        <u-cell-group>
          <view v-for="(item, idx) in dataList" :key="idx">
            <u-cell-item 
              :arrow="false" 
              :title="item.goodsName + '('+item.propSubTypeName+')'" 
              :label="getLabel(item)"
              @tap="handlerSelect(item)"
            >
              <u-icon
                name="checkbox-mark"
                color="#2979ff"
                size="38"
                v-if="selectIds.includes(item.goodsRdmUuid)"
                slot="right-icon"
              ></u-icon>
            </u-cell-item>
          </view>
        </u-cell-group>
      </view>
    </view>
  </view>
</template>

<script> 
/** 
 * 指定选择
 */
export default {
  name: "MergeGoodsPick",
  props: {
    dataList:{
      type: Array,
      default: () => { return []; },
    },
  },
  data() {
    return {
      selectItems: [],  // 选中项
      selectIds: [],    // 选中的id
    };
  }, 
  onLoad() {
	
  },
  created() {
    
  },
  methods: {
    // 点击根节点
    handlerSelect(orgItem) {
      this.selectItems = [];
      this.selectIds = [];
      this.selectItems.push(orgItem);
      this.selectIds.push(orgItem.goodsRdmUuid);
    },
    getLabel(item){
      return "来源地: " + item.sourceAddrName + "  去向地: " + item.toAddrName + "  环节: " + item.getNodeName;	
    },
    // 点击确定
    onSure() {
      if(this.selectItems.length == 0) {
        this.$u.toast('请至少选择一项');
        return;
      }
      this.$emit("choose", this.selectItems[0]);
    },
  },
};
</script>

<style lang="scss" scoped>

#orgListContainer {
  margin-top: 5px;
}
.nav-right-icon {
  padding-right: 15px;
  color: #FFF;
}
/deep/ .u-tab-item {
  max-width: 160px;
}
</style>